///////////////////////////////////////
//    Autor: Mato Kormuth              //
//    (C) Mato Programs 2011        //
//////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MatoPrograms.ImageFilters
{
    public partial class HueChanger : Form
    {
        AForge.Imaging.Filters.HueModifier filter;
        public HueChanger()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            colorDialog1.ShowDialog();
            label1.Text = colorDialog1.Color.ToArgb().ToString();
            label2.Text = "Hue:" + colorDialog1.Color.GetHue().ToString() + "Saturation:" + colorDialog1.Color.GetSaturation().ToString() + "Brightness:" + colorDialog1.Color.GetBrightness().ToString();
            //if mbmc is active
            colorDialog2.ShowDialog();
            colorDialog3.ShowDialog();
            colorDialog4.ShowDialog();
            colorDialog5.ShowDialog();
            colorDialog6.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            textBox1.Text = openFileDialog1.FileName;
            pictureBox1.ImageLocation = textBox1.Text;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            progressBar1.Value = 0;
            // load an image

            System.Drawing.Bitmap image = (Bitmap) Bitmap.FromFile(textBox1.Text);
            // format image

            AForge.Imaging.Image.FormatImage(ref image);
            filter = new AForge.Imaging.Filters.HueModifier();
            filter.Hue = (int)colorDialog1.Color.GetHue();
            System.Drawing.Bitmap output = filter.Apply(image);
            output.Save("C:/mbmctmp/mphuechanout2.bmp");
            pictureBox2.Load("C:/mbmctmp/mphuechanout2.bmp");
            progressBar1.Value = 10;
            //if mbmc is active
            filter = new AForge.Imaging.Filters.HueModifier();
            filter.Hue = (int)colorDialog2.Color.GetHue();
            System.Drawing.Bitmap outputt = filter.Apply(image);
            outputt.Save("C:/mbmctmp/mphuechanout3.bmp");
            pictureBox3.Load("C:/mbmctmp/mphuechanout3.bmp");
            progressBar1.Value = 25;
            filter = new AForge.Imaging.Filters.HueModifier();
            filter.Hue = (int)colorDialog3.Color.GetHue();
            System.Drawing.Bitmap outputtt = filter.Apply(image);
            outputtt.Save("C:/mbmctmp/mphuechanout4.bmp");
            pictureBox4.Load("C:/mbmctmp/mphuechanout4.bmp");
            progressBar1.Value = 40;
            filter = new AForge.Imaging.Filters.HueModifier();
            filter.Hue = (int)colorDialog4.Color.GetHue();
            System.Drawing.Bitmap outputu = filter.Apply(image);
            outputu.Save("C:/mbmctmp/mphuechanout5.bmp");
            pictureBox5.Load("C:/mbmctmp/mphuechanout5.bmp");
            progressBar1.Value = 50;
            filter = new AForge.Imaging.Filters.HueModifier();
            filter.Hue = (int)colorDialog5.Color.GetHue();
            System.Drawing.Bitmap outputuu = filter.Apply(image);
            outputuu.Save("C:/mbmctmp/mphuechanout6.bmp");
            pictureBox6.Load("C:/mbmctmp/mphuechanout6.bmp");
            progressBar1.Value = 75;
            filter = new AForge.Imaging.Filters.HueModifier();
            progressBar1.Value = 76;
            filter.Hue = (int)colorDialog6.Color.GetHue();
            progressBar1.Value = 77;
            System.Drawing.Bitmap outputuuu = filter.Apply(image);
            progressBar1.Value = 78;
            outputuuu.Save("C:/mbmctmp/mphuechanout7.bmp");
            progressBar1.Value = 79;
            pictureBox7.Load("C:/mbmctmp/mphuechanout7.bmp");
            progressBar1.Value = 80;
            button4.Enabled = true;
            button3.Enabled = true;
            button2.Enabled = true;
            button1.Enabled = true;
            progressBar1.Value = 100;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            
            folderBrowserDialog1.ShowDialog();
            //if mbmc is active
            progressBar1.Value = 0;
            pictureBox1.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "_original.png");
            progressBar1.Value = 10;
            pictureBox2.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "1.png");
            progressBar1.Value = 20;
            pictureBox3.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "2.png");
            progressBar1.Value = 35;
            pictureBox4.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "3.png");
            progressBar1.Value = 55;
            pictureBox5.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "4.png");
            progressBar1.Value = 75;
            pictureBox6.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "5.png");
            progressBar1.Value = 90;
            pictureBox7.Image.Save(folderBrowserDialog1.SelectedPath + "/" + textBox2.Text + "6.png");
            progressBar1.Value = 100;
        }

        private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void HueChanger_Load(object sender, EventArgs e)
        {

        }
    }
}